package com.work.service.impl;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.work.domain.CompanyIndexInfo;
import com.work.domain.CompanyInfo;
import com.work.domain.CompanySearchtype;
import com.work.domain.CompanyTopInfo;
import com.work.mapper.CompanyInfoMapper;
import com.work.mapper.CompanySearchtypeMapper;
import com.work.service.CompanyInfoService;

@Service
public class CompanyInfoServiceImpl implements CompanyInfoService{

	//公司信息mapper
	@Resource
	private CompanyInfoMapper companyInfoMapper;
	//公司内容搜索类型mapper
	@Resource
	private CompanySearchtypeMapper companySearchtypeMapper;
	
	
	//查询公司所有列表信息
	@Override
	public List<CompanyInfo> findAllCompanyInfo() {
		// TODO Auto-generated method stub
		return companyInfoMapper.findAllCompanyInfo();
	}
	//查询公司首页信息
	@Override
	public List<CompanyIndexInfo> findAllCompanyIndexInfo() {
		// TODO Auto-generated method stub
		return companyInfoMapper.findAllCompanyIndexInfo();
	}
	//查询公司首页推荐位信息列表
	@Override
	public List<CompanyTopInfo> findAllCompanyTopIndexInfo() {
		// TODO Auto-generated method stub
		return companyInfoMapper.findAllCompanyTopInfo();
	}
	//根据Cid查询公司详情信息
	@Override
	public CompanyInfo findCompanyInfoByCid(Integer cid) {
		// TODO Auto-generated method stub
		return companyInfoMapper.findCompanyInfoByCid(cid);
	}
	//根据条件查询企业列表信息
	@Override
	public List<CompanyIndexInfo> findCompanyListByConditions(String type, String value) {
		// TODO Auto-generated method stub
		String percent="%";
		List<CompanyIndexInfo> list= new ArrayList<CompanyIndexInfo>();
		//选择为空
		if("".equals(type)|| type==null){
			value=percent.concat(value).concat(percent);
			list=companyInfoMapper.findCompanyListByAllConditions(value);
		}else if("cname".equals(type)){
			value=percent.concat(value).concat(percent);
			list=companyInfoMapper.findCompanyListByCname(value);
		}else if("caddress".equals(type)){
			value=percent.concat(value).concat(percent);
			list=companyInfoMapper.findCompanyListByCaddress(value);
		}else if("ccount".equals(type)){
			value=percent.concat(value).concat(percent);
			list=companyInfoMapper.findCompanyListByCcount(value);
		}
		return list;
	}
	//android查询公司模糊搜索类型
	@Override
	public List<CompanyIndexInfo> findCompanySearchType() {
		// TODO Auto-generated method stub
		return companySearchtypeMapper.findCompanySearchType();
	}
	//根据id删除公司信息
	@Override
	public Integer deleteCompanyById(int cid) {
		// TODO Auto-generated method stub
		return companyInfoMapper.deleteCompanyById(cid);
	}
	//编辑公司信息
	@Override
	public void updateCompanyInfo(CompanyInfo companyInfo) {
		// TODO Auto-generated method stub
		companyInfoMapper.updateCompanyInfo(companyInfo);
	}
	//web查询公司模糊搜索类型
	@Override
	public List<CompanyInfo> findCompanyListByConditionsWeb(String cname, String caddress, String ccount,String clabourcost) {
		// TODO Auto-generated method stub
		return companyInfoMapper.findCompanyListByConditionsWeb(cname,caddress,ccount,clabourcost);
	}
	//web端添加公司信息
	@Override
	public Integer saveCompanyInfo(CompanyInfo ci) {
		// TODO Auto-generated method stub
		return companyInfoMapper.saveCompanyInfo(ci);
	}
    //添加公司模糊搜索类型
	@Override
	public Integer addCompanySearchTypeWeb(CompanySearchtype companySearchtype) {
		// TODO Auto-generated method stub
		return companySearchtypeMapper.addCompanySearchTypeWeb(companySearchtype);
	}
	//删除公司模糊搜索类型
	@Override
	public Integer deleteCompanySearchById(int cid) {
		// TODO Auto-generated method stub
		return companySearchtypeMapper.deleteCompanySearchById(cid);
	}
	//前台分页：获取公司总数量
	@Override
	public int findCompanyCount() {
		// TODO Auto-generated method stub
		return companyInfoMapper.findCompanyCount();
	}
	//前台分页：获取公司分页信息
	@Override
	public List<CompanyIndexInfo> findCompanyPage(int startPos, int pageSize) {
		// TODO Auto-generated method stub
		return companyInfoMapper.findCompanyPage(startPos,pageSize);
	}
	
	

}
